const express = require('express')

const app = express()

const mw1 = (req, res, next) => {
  console.log('这是最简单的中间件函数1')
  next()
}

const mw2 = (req, res, next) => {
  console.log('这是最简单的中间件函数2')
  next()
}

// 全局注册的中间件函数会在所有路由之前依次执行
app.use(mw1)
app.use(mw2)

app.get('/', (req, res) => {
  res.send('Home page.')
  console.log('访问了/路径')
})
 
app.listen(80, () => {
  console.log('express server running at http://127.0.0.1')
})